package Servlets;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import DB.DAOManager;

public class CurrentFee extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException{
		
		try {
			DAOManager dao=new DAOManager();
			System.out.println("Current");
			Connection conn=dao.getConnection();
			PreparedStatement pstmt= conn.prepareStatement("select  TransactionFeeValue from TransactionFee where TransactionFeeId=(select max(TransactionFeeId ) from TransactionFee)");
			ResultSet rs=pstmt.executeQuery();
			rs.next();
		 int value=	rs.getInt("TransactionFeeValue");
		 System.out.println("value is "+value);
		 HttpSession ses=req.getSession(true);
		 ses.setAttribute("cvalue", value);
		// PrintWriter out=res.getWriter();
	//	 out.println(value);
			
			
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException{
		doPost(req,res);
		
	}
}
